<%-- 
    Document   : mainPage
    Created on : 2008-2-24, 10:10:29
    Author     : Hovanessyan
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="pa" uri="http://agil.com"%>

<%@ page isELIgnored="false"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.util.List"%>
<%@page import="com.agil.photoalbum.db.entities.Picture"%>
<%@page import="com.agil.photoalbum.db.dao.Functions"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Главна страница</title>
        <link type="text/css" rel="stylesheet" href="/photo-album/styles/mainPage.css" />
    </head>
    <body>
        <div id="wrapper">
            
			<jsp:include page="header.jsp" />
			

            <div id="holder">
                <div id="bullshet">
                    <div id="main">
                    	
                        <h1>Random pictures: </h1>
                        
                        <table class="thumbnails">
                        
                        	<c:set var="counter" value="0"> </c:set>
                        	<c:if test="${empty criteria}">
	                         	<c:set var="listOfPictures" value="${pa:getAllPicturesByDate()}" />
	                       </c:if>
	                       <c:if test="${not empty criteria}">
	                         <c:set var="listOfPictures" value="${listOfFoundPictures}" />
	                       </c:if>
	                       <c:forEach var="pic" begin="0" end="15" step="1" items="${listOfPictures}">
	                       		<c:if test="${counter==0}">
		                       			<tr>
		                       	</c:if>
	                       
                       			<c:if test="${counter%4==0 && counter!=0}">
                       					</tr>
		                       			<tr>
		                       	</c:if>
	                        	
		                        	<td>
		                        	
										<a href="#">
                                            <img src="/photo-album${pic.picturePath}" alt="" />
                                            <h4><c:out value='${pic.pictureName}'/></h4>
                                            
                                        </a>
									</td>
								
								<c:set var="counter" value="${counter + 1}" />
							</c:forEach>
                        </table>
                        
                    </div>
                    <div id="sidebar"> 
                        <div id="searchbar">
                            <form action="/photo-album/SearchServlet" method="post">
                            	<input type="hidden" name="backTo" value="main">
                                <label for="search" accesskey="s">Search</label>
                                <br />
                                <input type="text" id="search" name="criteria" value="" class="stxt" />
                                <input type="submit" name="submit" value="Search" />
                            </form>
                            <form action="/photo-album/LoginServlet" method="post">
                            	<br/>
                            	<label>Username: </label>
                            	<input type="text" name="username"/>
                            	<br/>
                            	<label>Password: </label>
                            	<input type="password" name="password"/>
                            	<br/>
                            	<input type="submit" name="submit" value="Log In" />
                            	<a href="/photo-album/pages/registerForm.jsp">Register</a>
                            </form>
                        </div>
                        <div id="userlist">
                            <h3>Users: </h3>
                            <ul>
                            
                            <c:forEach var="user" items="${pa:getAllUsers()}">
								<li>
									<a href="/photo-album/pages/homePage.jsp?userId=${user.userId}"><c:out value='${user.userName}'/></a>
								</li>
							</c:forEach>
                            
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            
			<jsp:include page="footer.jsp" />
        </div>
    </body>
</html>
